home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 126-150 / disk_148 / fme / source / chgcolor.c next >
C/C++ Source or Header  |  1992-05-06  |  5KB  |  141 lines

  1. #include "stdio.h"
  2. #include "exec/types.h"
  3. int map[33][65], x, y;
  4. char c, *colors, name[40];
  5. FILE *in, *out;
  6. main()
  7. {
  8.    printf("Change map to (g)reen or (b)rown? ");
  9.    c = getchar();
  10.    if (c=='g')
  11.        colors = "green";
  12.    else if (c=='b')
  13.        colors = "brown";
  14.    else exit(0);
  15.    printf("Enter name of map to change to %s ",colors);
  16.    gets(name);
  17.    gets(name);
  18.    if ((in = fopen(name,"r")) == NULL)
  19.      {
  20.         printf("Error opening file.\n");
  21.         exit(0);
  22.      }
  23.    for (x=1;x<33;x++)
  24.       {
  25.          for (y=1;y<65;y++)
  26.                map[x][y] = getc(in);
  27.       }
  28.    fclose(in);
  29.  
  30.    if (c=='g')
  31.      {
  32.         for (x=1;x<33;x++)
  33.            {
  34.               for (y=1;y<65;y++)
  35.                  {
  36.                     if (map[x][y] < 5) continue;
  37.                       switch (map[x][y])
  38.                           {
  39.                              case 20 : map[x][y] = 32;
  40.                                        break;
  41.                              case 44 : map[x][y] = 67;
  42.                                        break;
  43.                              case 17 : map[x][y] = 29;
  44.                                        break;
  45.                              case 18 : map[x][y] = 30;
  46.                                        break;
  47.                              case 19 : map[x][y] = 31;
  48.                                        break;
  49.                              case 22 : map[x][y] = 34;
  50.                                        break;
  51.                              case 24 : map[x][y] = 36;
  52.                                        break;
  53.                              case 25 : map[x][y] = 37;
  54.                                        break;
  55.                              case 89 : map[x][y] = 92;
  56.                                        break;
  57.                              case 42 : map[x][y] = 65;
  58.                                        break;
  59.                              case 47 : map[x][y] = 70;
  60.                                        break;
  61.                              case 27 : map[x][y] = 39;
  62.                                        break;
  63.                              case 85 : map[x][y] = 87;
  64.                                        break;
  65.                              case 41 : map[x][y] = 64;
  66.                                        break;
  67.                              case 43 : map[x][y] = 66;
  68.                                        break;
  69.                              case 48 : map[x][y] = 71;
  70.                                        break;
  71.                              case 50 : map[x][y] = 73;
  72.                           }
  73.                  }
  74.            }
  75.      strcat(name,".g");
  76.      }
  77.  
  78.    if (c=='b')
  79.      {
  80.         for (x=1;x<33;x++)
  81.            {
  82.               for (y=1;y<65;y++)
  83.                  {
  84.                     if (map[x][y] < 5) continue;
  85.                       switch (map[x][y])
  86.                           {
  87.                              case 32 : map[x][y] = 20;
  88.                                        break;
  89.                              case 67 : map[x][y] = 44;
  90.                                        break;
  91.                              case 29 : map[x][y] = 17;
  92.                                        break;
  93.                              case 30 : map[x][y] = 18;
  94.                                        break;
  95.                              case 31 : map[x][y] = 19;
  96.                                        break;
  97.                              case 34 : map[x][y] = 22;
  98.                                        break;
  99.                              case 36 : map[x][y] = 24;
  100.                                        break;
  101.                              case 37 : map[x][y] = 25;
  102.                                        break;
  103.                              case 92 : map[x][y] = 89;
  104.                                        break;
  105.                              case 65 : map[x][y] = 42;
  106.                                        break;
  107.                              case 70 : map[x][y] = 47;
  108.                                        break;
  109.                              case 39 : map[x][y] = 27;
  110.                                        break;
  111.                              case 87 : map[x][y] = 85;
  112.                                        break;
  113.                              case 64 : map[x][y] = 41;
  114.                                        break;
  115.                              case 66 : map[x][y] = 43;
  116.                                        break;
  117.                              case 71 : map[x][y] = 48;
  118.                                        break;
  119.                              case 73 : map[x][y] = 50;
  120.                           }
  121.                  }
  122.            }
  123.      strcat(name,".b");
  124.      }
  125.  
  126.    if ((out = fopen(name,"w")) == NULL)
  127.      {
  128.         printf("Error writing file.\n");
  129.         exit(0);
  130.      }
  131.    for (x=1;x<33;x++)
  132.       {
  133.          for (y=1;y<65;y++)
  134.                putc(map[x][y],out);
  135.       }
  136.    fclose(out);
  137.    
  138. }
  139.  
  140.  
  141.